<script>
  layui.config({
    base: '/static/customAdmin/',
  }).extend({
    index: 'lib/index',
  }).use(['index', 'layuiXtree'], async () => {
    let { form, admin, layuiXtree } = layui,
      perms = await admin.get(`/role/perm_lists/` + @{{.m.Id}}),
      permission = new layuiXtree({
        elem: 'permission'
        , form: form
        , data: perms.obj.data
        , isopen: false
        , ckall: true,
      })

    form.on('submit(role_submit)', async (data) => {
      data.field.urlForstrings = permission.GetChecked().toString()
      let result = await admin.patch(`/role/update/` + "@{{ .m.Id }}", data.field)
      if (result.status) {
        setTimeout(() => {
          admin.reloadFrame('角色管理iframe')
        }, 150)
      }
    })
  })
</script>